layui.use(['table', 'admin', 'ax','laydate'], function () {
    var $ = layui.$;
    var table = layui.table;
    var $ax = layui.ax;
    var admin = layui.admin;
    var laydate = layui.laydate;

    laydate.render({
        elem: '#currentDate'
        ,value:new Date()
    });
    /**
     * 出库订单表管理
     */
    var OutOrder = {
        tableId: "jhzyjdTable"
    };



    /**
     * 初始化表格的列
     */
    OutOrder.initColumn = function () {
        return [[

            {field: 'getUnit', title: '拣货单类型', style:'color: #2b85e4;font-weight: 600;',width:150},
            {field: 'storageOutStatus', title: '商品复核状态', templet: '#outOrderStatusTpl', event: 'outOrderStatusSign' ,totalRowText: '合计：'},
            {field: 'recordCount', title: '单数', style:'font-weight: 600;',totalRow: true},
            {field: 'linePutbalenum', title: '行数',totalRow: true},
            {field: 'storagePutbalenum', title: ' 商品数', style:'font-weight: 600;',totalRow: true},

        ]];
    };

    /**
     * 点击查询按钮
     */
    OutOrder.search = function () {
        var queryData = {};
        queryData['currentDate'] = $("#currentDate").val();
        table.reload(OutOrder.tableId, {
            where: queryData, page: {curr: 1},
            done:function () {

            }
        });

    };

    // 渲染表格
    var tableResult = table.render({
        elem: '#' + OutOrder.tableId,
        url: Feng.ctxPath + '/packReview/getFhzyjdList',
        page: true,
        limit: 30,
        height: 410,
        toolbar: '#demotoolbarfrom',
        cellMinWidth: 100,
        totalRow: true,
        cols: OutOrder.initColumn()
    });


    // 搜索按钮点击事件
    $('#btnSearch').click(function () {
        OutOrder.search();
    });

    // 工具条点击事件
    table.on('tool(' + OutOrder.tableId + ')', function (obj) {
        var data = obj.data;
        var layEvent = obj.event;

        if (layEvent === 'edit') {
            OutOrder.openEditDlg(data);
        }else if (obj.event === 'outOrderStatusSign' && data.outOrderStatus == '驳回'){
            var index = layer.open({
                title: '审核详情：',
                type: 1,
                title: false, //不显示标题栏
                closeBtn: false,
                shade: 0.3,
                area: '300px;',
                content: "<div style='padding: 50px; word-wrap: break-word;word-break: break-all;overflow: hidden; background-color: #000000; color: #fff;line-height: 22px;  font-weight: 300;'>审核人："+data.examineName+"<br><br>审核时间："+data.examineTime+"<br><br>批注：<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"+data.returnNote+"</div>",
                btn: ['确定'] ,
                btnAlign: 'c' ,//按钮居中
                yes: function(){
                    layer.close(index);
                }
            });
        }
    });

});
